define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        //找人启事
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'something/index' + location.search,
                    // add_url: 'something/add',
                    edit_url: 'something/edit',
                    // del_url: 'something/del',
                    multi_url: 'something/multi',
                    table: 'something',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showExport:false,
                searchFormVisible: true,
                search:false,
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'id', title: __('Id'),operate:false},
                        {field: 'images', title: __('Images'), events: Table.api.events.image, formatter: Table.api.formatter.images,operate:false},
                        {field: 'eurekaimages', title: __('找到图片集'), events: Table.api.events.image, formatter: Table.api.formatter.images,operate:false},
                        {field: 'money', title: __('Money'), operate:false},

                        // {field: 'content', title: __('Content'), operate:false},
                        // {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'cycle', title: __('Cycle'), searchList: {"1":__('Cycle 1'),"2":__('Cycle 2')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'user.nickname', title: __('User.nickname'),operate:false},
                        {field: 'contacts', title: __('Contacts'),operate:false},
                        {field: 'iphone', title: __('Iphone'),operate:false},
                        {field: 'receiverUser.nickname', title: __('找到的'),operate:false},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"6":__('Status 6'),"7":__('Status 7')}, formatter: Table.api.formatter.status},
                        {field: 'detailedaddress', title: __('Detailedaddress'),operate:'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'browse', title: __('Browse'),operate:false},
                        {field: 'partner_trade_no', title: __('支付订单号'),operate:false},
                        // {field: 'user.username', title: __('User.username'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
                            buttons: [

                                {
                                    name: 'addtabs',
                                    text: __('赏金明细'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'income/moneyreward'
                                },
                                {
                                    name: 'addtabs',
                                    text: __('聊天记录'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'chatlog/index'
                                }

                            ],
                            formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        //招物启事
        findthings: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'something/findthings' + location.search,
                    // add_url: 'something/add',
                    edit_url: 'something/edit',
                    // del_url: 'something/del',
                    multi_url: 'something/multi',
                    table: 'something',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showExport:false,
                searchFormVisible: true,
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate:false},
                        {field: 'images', title: __('Images'), events: Table.api.events.image, formatter: Table.api.formatter.images,operate:false},
                        {field: 'eurekaimages', title: __('找到图片集'), events: Table.api.events.image, formatter: Table.api.formatter.images,operate:false},

                        {field: 'money', title: __('Money'), operate:false},
                        // {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'cycle', title: __('Cycle'), searchList: {"1":__('Cycle 1'),"2":__('Cycle 2')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'user.nickname', title: __('User.nickname'),operate:false},
                        {field: 'receiverUser.nickname', title: __('找到的'),operate:false},
                        {field: 'contacts', title: __('Contacts'),operate:false},
                        {field: 'iphone', title: __('Iphone'),operate:false},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"6":__('Status 6'),"7":__('Status 7')}, formatter: Table.api.formatter.status},
                        {field: 'detailedaddress', title: __('Detailedaddress'),operate:'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'browse', title: __('Browse'),operate:false},
                        {field: 'partner_trade_no', title: __('支付订单号'),operate:false},
                        // {field: 'user.username', title: __('User.username'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
                            buttons: [

                                {
                                    name: 'addtabs',
                                    text: __('赏金明细'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'income/moneyreward'
                                },
                                {
                                    name: 'addtabs',
                                    text: __('聊天记录'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'chatlog/index'
                                }

                            ],
                            formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        //失物招领
        lostarticle: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'something/lostarticle' + location.search,
                    // add_url: 'something/add',
                    edit_url: 'something/edit',
                    // del_url: 'something/del',
                    multi_url: 'something/multi',
                    table: 'something',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                showExport:false,
                searchFormVisible: true,
                search:false,
                columns: [
                    [
                        // {checkbox: true},
                        {field: 'id', title: __('Id'),operate:false},
                        {field: 'images', title: __('Images'), events: Table.api.events.image, formatter: Table.api.formatter.images,operate:false},
                        {field: 'eurekaimages', title: __('失主图片集'), events: Table.api.events.image, formatter: Table.api.formatter.images,operate:false},

                        {field: 'money', title: __('Money'), operate:false},
                        // {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2'),"3":__('Type 3')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'cycle', title: __('Cycle'), searchList: {"1":__('Cycle 1'),"2":__('Cycle 2')}, formatter: Table.api.formatter.normal,operate:false},
                        {field: 'user.nickname', title: __('User.nickname'),operate:false},
                        {field: 'contacts', title: __('Contacts'),operate:false},
                        {field: 'receiverUser.nickname', title: __('失主'),operate:false},
                        {field: 'iphone', title: __('Iphone'),operate:false},
                        {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"6":__('Status 6'),"7":__('Status 7')}, formatter: Table.api.formatter.status},
                        {field: 'detailedaddress', title: __('Detailedaddress'),operate:'LIKE'},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'browse', title: __('Browse'),operate:false},
                        {field: 'partner_trade_no', title: __('支付订单号'),operate:false},
                        // {field: 'user.username', title: __('User.username'),operate:false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
                            buttons: [

                                {
                                    name: 'addtabs',
                                    text: __('报酬明细'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'income/moneyreward'
                                },
                                {
                                    name: 'addtabs',
                                    text: __('聊天记录'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-list',
                                    url: 'chatlog/index'
                                }

                            ],

                            formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});